package com.sbtr.open.trainingmodel.dto;

import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.util.Date;

public class TrainingModelDataDto implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 模型未发布
	 */
	public static final String MODEL_STATUS_UNPUBLISH = "unpublish";
	/**
	 * 模型已发布
	 */
	public static final String MODEL_STATUS_PUBLISHED = "published";
	/**
	 * 模型版本模式
	 */
	public static final String MODEL_VERSION_PATTERN = "V\\d+[.]\\d+";

	/**
	 * 主键
	 */
	private Long id;

	/**
	 * 模型名称
	 */
	private String modelName;

	/**
	 * 关联项目名称
	 */
	private Long projectId;

	/**
	 * 模型版本
	 */
	private String version;

	/**
	 * 模型状态（发布/停用）
	 */
	private String status;

	/**
	 * 模型剩余时间，s为单位
	 */
	private Long remainTime;

	/**
	 * 模型文件存放路径
	 */
	private String modelDir;

	/**
	 * 模型训练开始时间
	 */
	private Date createTime;

	/**
	 * 训练任务id
	 */
	private Long taskId;

	/**
	 * 创建者
	 */
	private String creater;

	/**
	 * 离线模型文件保存路径
	 */
	private String sdkModelDir;

	/**
	 * 模型评估结果
	 */
	private String evaluate;

	/**
	 * 长度
	 */
	private String classifier;

	/**
	 * 模型训练结束时间
	 */
	private Date endTime;

	/**
	 * 算法名称
	 */
	private String arithmetic;

	/**
	 * 逻辑/线性回归公式
	 */
	private String logisticFormula;

	/**
	 * 任务类型 0:分类 1:检测
	 */
	private String type;

	/**
	 * 标签信息
	 */
	private String classify;

	/**
	 * 项目名称
	 */
	private String projectName;

	/**
	 * 聚类与相关性的预测结果
	 */
	private String predict_file;

	/**
	 * 聚类中心点数据
	 */
	private String center;



	/**
	 * 应用类型
	 */
	private String applicationType;

	/**
	 * 模型类型
	 */
	private String modelType;

	/**
	 * 数据集名称
	 */
	private String materialSetName;

	/**
	 * 是否外部导入的模型,1:否；2：是
	 */
	private int isExternalImport;

	/**
	 * 模型文件类型：sklearn；matlab
	 */
	private String modelFileType;

	/**
	 * 测试接口
	 */
	private String api;

	public String getApplicationType() {
		return applicationType;
	}

	public void setApplicationType(String applicationType) {
		this.applicationType = applicationType;
	}

	public String getModelType() {
		return modelType;
	}

	public void setModelType(String modelType) {
		this.modelType = modelType;
	}

	public String getMaterialSetName() {
		return materialSetName;
	}

	public void setMaterialSetName(String materialSetName) {
		this.materialSetName = materialSetName;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getModelName() {
		return modelName;
	}

	public void setModelName(String modelName) {
		this.modelName = modelName;
	}

	public Long getProjectId() {
		return projectId;
	}

	public void setProjectId(Long projectId) {
		this.projectId = projectId;
	}

	public String getVersion() {
		return version;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public Long getRemainTime() {
		return remainTime;
	}

	public void setRemainTime(Long remainTime) {
		this.remainTime = remainTime;
	}

	public String getModelDir() {
		return modelDir;
	}

	public void setModelDir(String modelDir) {
		this.modelDir = modelDir;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Long getTaskId() {
		return taskId;
	}

	public void setTaskId(Long taskId) {
		this.taskId = taskId;
	}

	public String getCreater() {
		return creater;
	}

	public void setCreater(String creater) {
		this.creater = creater;
	}

	public String getSdkModelDir() {
		return sdkModelDir;
	}

	public void setSdkModelDir(String sdkModelDir) {
		this.sdkModelDir = sdkModelDir;
	}

	public String getEvaluate() {
		return evaluate;
	}

	public void setEvaluate(String evaluate) {
		this.evaluate = evaluate;
	}

	public String getClassifier() {
		return classifier;
	}

	public void setClassifier(String classifier) {
		this.classifier = classifier;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public String getArithmetic() {
		return arithmetic;
	}

	public void setArithmetic(String arithmetic) {
		this.arithmetic = arithmetic;
	}

	public String getLogisticFormula() {
		return logisticFormula;
	}

	public void setLogisticFormula(String logisticFormula) {
		this.logisticFormula = logisticFormula;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getClassify() {
		return classify;
	}

	public void setClassify(String classify) {
		this.classify = classify;
	}

	public String getProjectName() {
		return projectName;
	}

	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}

	public String getPredict_file() {
		return predict_file;
	}

	public void setPredict_file(String predict_file) {
		this.predict_file = predict_file;
	}

	public String getCenter() {
		return center;
	}
	
	public void setCenter(String center) {
		this.center = center;
	}

	public int getIsExternalImport() {
		return isExternalImport;
	}

	public void setIsExternalImport(int isExternalImport) {
		this.isExternalImport = isExternalImport;
	}

	public String getModelFileType() {
		return modelFileType;
	}

	public void setModelFileType(String modelFileType) {
		this.modelFileType = modelFileType;
	}

	public String getApi() {
		return api;
	}

	public void setApi(String api) {
		this.api = api;
	}

	/**
	 * 升级模型版本
	 * 
	 * @return
	 */
	public static final String upgradeVersion(String baseVersion) {

		if (!StringUtils.isEmpty(baseVersion) && baseVersion.matches(MODEL_VERSION_PATTERN)) {
			double vNum = Double.parseDouble(baseVersion.replaceAll("V", ""));
			return String.format("V%.1f", vNum + 0.1);
		}
		return String.format("V%.1f", 1.0);
	}
}
